package com.dyp.multi_data_source.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.dyp.multi_data_source.entity.Author;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Service
public class AuthorService {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @DS("master")
    public String slectctById(){
        return jdbcTemplate.queryForObject("select name from author where id=1",String.class);
    }

    @DS("slave1")
    public String select(){
        return jdbcTemplate.queryForObject("select name from author where id=1",String.class);
    }
}
